<template>
    <div>
        <h2>{{ store.state.count }} , {{ state.count }}, {{ count }}</h2>
        <p>
            <button @click="store.commit('add', 10)">++</button>
        </p>
        <h3>user模块的数据： {{ store.state.user.age }} , {{ state.user.age }}</h3>
        <p>
            <button @click="store.commit('user/addAge', 9)">Age++</button>
        </p>
    </div>
</template>

<script setup>
/**
 *  Vuex 的使用过程：
 *      1. createStore
 *      2. app.use
 *      3. useStore
 *      4. 正常使用
 *          获取数据 store.state.xxx
 *          操作数据 store.commit('mutation',参数)
 * 
 */
import { toRefs } from 'vue';
import { useStore } from 'vuex'
const store = useStore();
console.log(store.state.count);
const { commit, state } = store
const { count } = toRefs(store.state)
</script>

<style scoped>

</style>